package teacher;

import com.tern.web.PageForm;
import com.tern.web.html;
import com.tern.data.Entity;
import com.tern.data.Record;
import com.tern.util.Convert;
import com.tern.util.Trace;
import com.tern.db.DBCommand;
import com.tern.db.SqlHelper;

public class StudentInfoPage extends PageForm{
private Entity centity;
private Entity sentity;
private int cid;
private int sid;
private Record row;
	final protected boolean onLoad() throws Exception
	{
		cid=Convert.parseInt(request.getParameter("id"));
		centity= Entity.createFromSchema("curricula");
		sentity = Entity.createFromSchema("students");
		if(!this.isPostBack)
		{
			retriveEntity();
		}
		return true;
	}
	
	private void retriveEntity()
	{
		try
		{
			centity.retriveFromDB("curriculaID="+cid);
			if(centity.getRowsCount()>0){
				Record r=centity.get(0);
				sid=Integer.parseInt(r.getOriValue("stuID").toString());
				sentity.retriveFromDB("stuID="+sid);
				if(sentity.getRowsCount()>0){
					row=sentity.get(0);
				}
			}
			
		}
		catch(Exception e)
		{
			Trace.out(Trace.Error, "retriveEntity",e);
		}
	}
	
	public java.util.Map<String, Object> getStudentInfo()
	{
		return row.getMap();
	}
}
	